package cn.com.se.多线程.ThreadPoolExecutorTest.ThreadExPool;

public class DaemonThread {

    public static void main(String[] args) throws Exception {
            DaemonTask t = new DaemonTask();
            t.setDaemon(true);// this is set t thread as a daemon thread.
            t.start();
            Thread.sleep(2000);
            System.out.println("main thread exit.");

    }

}


class DaemonTask extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("i=" + i);
        }
    }
}
